<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>将数组反转排序</title>
	</head>
	<body>
		<p>Banana,Orange,Apple,Mango</p>
		<p>40,100,1,5,25,10</p>
		<input id="btn" type="button" value="反转" onclick="myFunction()">
		<input id="btn1" type="button" value="添加" onclick="add()">
		<input id="btn2" type="button" value="字母排序" onclick="px()">
		<input id="btn3" type="button" value="数字排序" onclick="numpx()">
		<script>
			function myFunction(){	
			var fruits=["Banana","Orange","Apple","Mango"];
			fruits.reverse();
            document.writeln(fruits);
			}
			
			function add(){	
			var fruits=["Banana","Orange","Apple","Mango"];
			fruits.splice(1,0,"lemon");  
            document.writeln(fruits);
			}
			
			function px(){	
			var fruits=["Banana","Orange","Apple","Mango"];
			fruits.sort();
			document.writeln(fruits);
			}
			
			function numpx(){
				var a=[40,50,20,31,34,54,66,32];
				for(var i=0;i<a.length;i++){
                for(var j = i + 1;j<a.length;j++){
                if(a[i]>a[j]){
                var tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
                }
              }
            }
            document.writeln(a);
			}
			
			
			
		</script>
	</body>
</html>